﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Game.Protocol;
using MMOArpgServer.Pool;
using MMOArpgServer.Net;
using Google.Protobuf;
public class LoginHandler
{
    private int _clientID;
    public LoginHandler(int clientID)
    {
        _clientID = clientID;
        DispatchManager.GetInstance().ServerMsgDispatcher.Register(ProtocolType.Login, ProtocolArea.ClientToServer, ProtocolCommand.Login, LoginReq);
    }

    public void LoginReq(byte[] buffer)
    {
        ClientToken token = ClientPool.GetInstance().GetClientByID(_clientID);
        PacketLoginServerRes res = new PacketLoginServerRes();
        res.Type = ProtocolType.Login;
        res.Area = ProtocolArea.ServerToSingleClient;
        res.Command = ProtocolCommand.Login;
        res.ResErrorCode = ResponseErrorCode.ErrorSuccessfull;
        res.RoleID = _clientID;
        byte[] sendBuffer = res.ToByteArray(); ;
        token.SendMsg(sendBuffer);
    }

}

